class Grouping < ActiveRecord::Base

  belongs_to :report
  belongs_to :strategy
  
  has_many :questions

  # Returns text to show when prompting the grouping in a report
  def text
    self.header || (self.strategy.name unless self.strategy.nil?) || self.tab_name
  end

  def questions_for_role (role)
    self.questions.reject { |q| q.for_role(role).nil? }
  end
end
